package com.andyliu.sys.controller;

import com.andyliu.sys.pojo.SActionLog;
import com.andyliu.sys.service.LogService;
import com.andyliu.vo.ParamVO;
import com.andyliu.vo.Result;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * ClassName: LogAction
 * Description:
 * date: 2021/2/4 3:36 下午
 *
 * @author andyliu
 * @since JDK 1.8
 */
@RestController
@RequestMapping("/log")
@Api(tags = "日志管理")
public class LogAction {
    @Autowired
    private LogService logService;
    @PostMapping("/action/log")
    @ApiOperation(value = "资源访问日志",produces = "application/json"
    ,protocols = "POST")
    public Result<Object> actionLogData(ParamVO<SActionLog> log){
        PageInfo<SActionLog> page = logService.queryAactionLogByPage(log.getParam(), log.getPageNumber(), log.getPageSize());
        return Result.ok("",page);
    }
    @DeleteMapping("/action/delete")
    @ApiOperation(value="删除资源访问日志",
    protocols = "DELETE")
    public Result<Object> actionDelete(Integer[] ids){
        boolean status = logService.deleteActionLogs(ids);
        return Result.ok(status);
    }
}
